package com.xmg.mgrsite.base;

import com.xmg.p2p.base.util.JSONResult;
import com.xmg.p2p.business.query.MoneyWithdrawQueryObject;
import com.xmg.p2p.business.service.IMoneyWithdrawService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @BelongsProject: jinrong-website
 * @BelongsPackage: com.xmg.mgrsite.base
 * @author: Andy
 * @date: 2021.4.17 15:48
 * @Description: 体现审核控制器
 * @since JDK 1.8
 */
@Controller
public class MoneyWithdrawController {
    @Autowired
    private IMoneyWithdrawService moneyWithdrawService;

    /**
     * 后台体现审核
     *
     * @param qo    条件
     * @param model 模型
     * @return 返回页面
     */
    @RequestMapping("moneyWithdraw")
    public String moneyWithdrawList(@ModelAttribute("qo") MoneyWithdrawQueryObject qo, Model model) {
        model.addAttribute("pageResult", this.moneyWithdrawService.query(qo));
        return "moneywithdraw/list";
    }

    /**
     * 提现申请
     * @param id    ID
     * @param remark    备注信息
     * @param state 审核状态
     * @return  返回JSON的执行结果
     */
    @RequestMapping("moneyWithdraw_audit")
    @ResponseBody
    public JSONResult audit(Long id, String remark, int state) {
        JSONResult json = new JSONResult();
        try {
            this.moneyWithdrawService.audit(id,remark,state);
        }catch (Exception ex){
            ex.printStackTrace();
            json.setMsg(ex.getMessage());
            json.setSuccess(false);
        }
        return json;
    }
}
